﻿<UserControl
	x:Class="LegoMachine.View.DeviceSettingsView"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:s="clr-namespace:System;assembly=mscorlib"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:lmCls="clr-namespace:LegoMachine.UI.Controls"
	xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit">
	<Grid>
		<Grid.ColumnDefinitions>
			<ColumnDefinition Width="150" />
			<ColumnDefinition Width="16" />
			<ColumnDefinition Width="150" />
			<ColumnDefinition Width="16" />
			<ColumnDefinition Width="170" />
			<ColumnDefinition Width="16" />
			<ColumnDefinition Width="170" />
		</Grid.ColumnDefinitions>
		<GroupBox Grid.Row="0" Header="Основные" Style="{StaticResource GroupBoxSimpleStyle}">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="8" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="8" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<TextBlock Grid.Row="0" Grid.Column="0" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" Text="COM-порт:  " />
				<TextBox Grid.Row="0" Grid.Column="1" Text="{Binding Path=DeviceComPort, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
				<Button Grid.Row="2" Grid.ColumnSpan="2" Content="Подключиться" Command="{Binding DeviceConnectCommand}" />
				<Button Grid.Row="5" Grid.ColumnSpan="2" Content="Отключиться" Command="{Binding DeviceDisconnectCommand}" />
			</Grid>
		</GroupBox>
		<GroupBox Grid.Column="2" Header="Сонар" IsEnabled="{Binding Path=IsConnected}" Style="{StaticResource GroupBoxSimpleStyle}">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="8" />
					<RowDefinition Height="Auto" />
					<RowDefinition Height="8" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="Auto" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<TextBlock Grid.Column="0" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" Text="NXT-порт:  " />
				<ComboBox
					Grid.Column="1"
					ItemsSource="{Binding Path=SonarPortSelector}"
					SelectedItem="{Binding Path=SonarPortSelector.SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
					SelectedValuePath="DisplayValue" DisplayMemberPath="DisplayValue">
				</ComboBox>
				<Button Grid.Row="2" Grid.ColumnSpan="2" Content="Получить значение" Command="{Binding SonarGetValueCommand}" />
				<TextBox Grid.Row="4" Grid.ColumnSpan="2" IsReadOnly="True" IsEnabled="False"
					Text="{Binding Path=SonarTestValue, StringFormat='0.00'}" TextAlignment="Right"/>
			</Grid>
		</GroupBox>
		<GroupBox Grid.Column="4" Header="Двигатели" IsEnabled="{Binding Path=IsConnected}" Style="{StaticResource GroupBoxSimpleStyle}">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="10" />
					<RowDefinition Height="24" />
					<RowDefinition Height="10" />
					<RowDefinition Height="24" />
					<RowDefinition Height="10" />
					<RowDefinition Height="24" />
					<RowDefinition Height="10" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="90" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<TextBlock Grid.Row="0" Grid.Column="0" Text="NXT-порты:" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" />
				<ComboBox Grid.Row="0" Grid.Column="1"
					ItemsSource="{Binding Path=EnginePortsSelector}"
					SelectedItem="{Binding Path=EnginePortsSelector.SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
					SelectedValuePath="DisplayValue" DisplayMemberPath="DisplayValue">
				</ComboBox>
				<TextBlock Grid.Row="2" Grid.Column="0" Text="Мощность:" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" />
				<xctk:IntegerUpDown Grid.Row="2" Grid.Column="1"
					Value="{Binding Path=EngineStepPower, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
				</xctk:IntegerUpDown>
				<TextBlock Grid.Row="4" Grid.Column="0" Text="Шаг (полный):" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" />
				<xctk:IntegerUpDown Grid.Row="4" Grid.Column="1"
					Value="{Binding Path=EngineStepAngle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
				</xctk:IntegerUpDown>
				<!--<TextBlock Grid.Row="6" Grid.Column="0" Text="Шаг (сонара):" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" />
				<xctk:IntegerUpDown Grid.Row="6" Grid.Column="1"
					Value="{Binding Path=EngineStepSonarPartAngle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
				</xctk:IntegerUpDown>-->
				<Grid Grid.Row="8" Grid.ColumnSpan="2">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="*" />
						<ColumnDefinition Width="10 "/>
						<ColumnDefinition Width="*" />
						<ColumnDefinition Width="10 "/>
						<ColumnDefinition Width="*" />
					</Grid.ColumnDefinitions>
					<Button Grid.Column="0" Content="" Command="{Binding EngineStepBackwardFullCommand}" FontFamily="Segoe UI Symbol" />
					<Button Grid.Column="2" Content="⬛" Command="{Binding EngineStopFullCommand}" FontFamily="Segoe UI Symbol" />
					<Button Grid.Column="4" Content="" Command="{Binding EngineStepForwardFullCommand}" FontFamily="Segoe UI Symbol" />
				</Grid>
			</Grid>
		</GroupBox>
		<GroupBox Grid.Column="6" Header="Манипулятор" IsEnabled="{Binding Path=IsConnected}" Style="{StaticResource GroupBoxSimpleStyle}">
			<Grid>
				<Grid.RowDefinitions>
					<RowDefinition Height="Auto" />
					<RowDefinition Height="10" />
					<RowDefinition Height="24" />
					<RowDefinition Height="10" />
					<RowDefinition Height="24" />
					<RowDefinition Height="10" />
					<RowDefinition Height="24" />
					<RowDefinition Height="10" />
					<RowDefinition Height="Auto" />
				</Grid.RowDefinitions>
				<Grid.ColumnDefinitions>
					<ColumnDefinition Width="90" />
					<ColumnDefinition Width="*" />
				</Grid.ColumnDefinitions>
				<TextBlock Grid.Row="0" Grid.Column="0" Text="NXT-порт:" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" />
				<ComboBox Grid.Row="0" Grid.Column="1"
					ItemsSource="{Binding Path=ManipulatorPortSelector}"
					SelectedItem="{Binding Path=ManipulatorPortSelector.SelectedItem, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
					SelectedValuePath="DisplayValue" DisplayMemberPath="DisplayValue">
				</ComboBox>
				<TextBlock Grid.Row="2" Grid.Column="0" Text="Мощность:" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" />
				<xctk:IntegerUpDown Grid.Row="2" Grid.Column="1"
					Value="{Binding Path=ManipulatorPower, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
				</xctk:IntegerUpDown>
				<!--<TextBlock Grid.Row="4" Grid.Column="0" Text="Мин. раст:" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" />
				<xctk:IntegerUpDown
					Grid.Row="4" Grid.Column="1"
					IsReadOnly="True"
					Value="{x:Null}">
				</xctk:IntegerUpDown>-->
				<TextBlock Grid.Row="4" Grid.Column="0" Text="Макс. угол:" Style="{DynamicResource TextBlockStyleSecondaryBodyText}" VerticalAlignment="Center" />
				<xctk:IntegerUpDown
					Grid.Row="4" Grid.Column="1"
					IsReadOnly="True"
					Value="{Binding Path=ManipulatorMaxAngle, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
				</xctk:IntegerUpDown>
				<Grid Grid.Row="8" Grid.ColumnSpan="2">
					<Grid.ColumnDefinitions>
						<ColumnDefinition Width="*" />
						<ColumnDefinition Width="10 "/>
						<ColumnDefinition Width="*" />
						<ColumnDefinition Width="10 "/>
						<ColumnDefinition Width="*" />
					</Grid.ColumnDefinitions>
					<Button
						Grid.Column="0" Content="" FontFamily="Segoe UI Symbol"
						Command="{Binding ManipulatorStepLeftCommand}">
						<Button.CommandParameter>
							<s:Int32>530</s:Int32>
						</Button.CommandParameter>
					</Button>
					<Button
						Grid.Column="2" Content="⬛" FontFamily="Segoe UI Symbol"
						Command="{Binding ManipulatorStopCommand}" />
					<Button
						Grid.Column="4" Content="" FontFamily="Segoe UI Symbol"
						Command="{Binding ManipulatorStepRightCommand}">
						<Button.CommandParameter>
							<s:Int32>530</s:Int32>
						</Button.CommandParameter>
					</Button>
				</Grid>
			</Grid>
		</GroupBox>
	</Grid>
</UserControl>
